import {
  HttpApi
} from '../../../model/index.js'
const httpApi = new HttpApi
Page({
  data: {
    windowHeight: 100,
    selectedIndex: '0',
    records: [],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var login = wx.getStorageSync('login')
   
    //设置scroll-view高度
    wx.getSystemInfo({
      success: function (res) {
        console.log(res.windowHeight)
        that.setData({ windowHeight: res.windowHeight - 1 });
      }
    });
    that.classifySelect();
  },
  classifySelect(e) {
    var that = this;
    let records = [];
    let _records = [];
    var _data = [];
    let index = "";
    if (e == undefined) index = 0
    else
      index = e.currentTarget.dataset.num;
    httpApi.ljfl().then(res => {
      _data = res.data;
      let str = "";
      for (var i = 0; i < _data.length; i++) {
        str += _data[i];
      }
      _data = str.split("!");
      records = _data[index];
      var arr = records.split(",")
      var strr = "";
      var obj = {};
      for (var j = 0; j < arr.length; j++) {
        let _arr = arr[j].split("jpg");
        obj = {
          img: _arr[0] + "jpg",
          name: _arr[1],
        }
        _records.push(obj);
      }
      this.setData({ selectedIndex: index, records: _records });
    });

  },

})
